package com.zzy.mccjt.service.controller;

import com.github.pagehelper.PageInfo;
import com.zzy.mccjt.interfaces.system.MccjtAppUserSystemInterface;
import com.zzy.mccjt.autoconfigure.base.controller.BaseController;
import com.zzy.mccjt.pojo.common.CurrentUser;
import com.zzy.mccjt.service.common.framework.response.WebApiResponse;
import com.zzy.mccjt.service.common.util.UserUtils;
import com.zzy.mccjt.service.service.UserService;
import com.zzy.pojo.system.login.UserDTO;
import com.zzy.pojo.system.login.UserPageDTO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "用户管理")
@RestController
@Slf4j
public class UserController extends BaseController implements MccjtAppUserSystemInterface {
    @Autowired
    private UserService userService;

    @Override
    public WebApiResponse<UserDTO> getUserInfo() {
        CurrentUser currentUser = UserUtils.currentUser();
        Long userId = currentUser.getUserId();
        if (currentUser.getUserId()==-1000000L){
            return WebApiResponse.error("用户未登录");
        }
        return userService.getUserInfo();
    }

    @Override
    public WebApiResponse<PageInfo<UserDTO>> getPageList(UserPageDTO dto) {
        return userService.getPageList(dto);
    }
}
